From: kfraser@localhost.localdomain Date: Thu, 12 Oct 2006 13:25:51 +0000 (+0100) Subject: Fix privcmd mmap() on 64b architectures for regions larger than 2GB. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15615^2~9 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=8b17a36d176b7164479b16cf4e539b899af0885e;p=xen.git Fix privcmd mmap() on 64b architectures for regions larger than 2GB. Signed-off-by: Xin Li Signed-off-by: Keir Fraser --- diff --git a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c index 9459229664..ba67bec83e 100644 --- a/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c +++ b/linux-2.6-xen-sparse/drivers/xen/privcmd/privcmd.c @@ -139,7 +139,7 @@ static int privcmd_ioctl(struct inode *inode, struct file *file, /* Do not allow range to wrap the address space. */ rc = -EINVAL; - if ((msg.npages > (INT_MAX >> PAGE_SHIFT)) || + if ((msg.npages > (LONG_MAX >> PAGE_SHIFT)) || ((unsigned long)(msg.npages << PAGE_SHIFT) >= -va)) goto mmap_out; @@ -183,7 +183,7 @@ static int privcmd_ioctl(struct inode *inode, struct file *file, if (copy_from_user(&m, udata, sizeof(m))) return -EFAULT; - if ((m.num <= 0) || (m.num > (INT_MAX >> PAGE_SHIFT))) + if ((m.num <= 0) || (m.num > (LONG_MAX >> PAGE_SHIFT))) return -EINVAL; down_read(&mm->mmap_sem); @@ -191,7 +191,8 @@ static int privcmd_ioctl(struct inode *inode, struct file *file, vma = find_vma(mm, m.addr); if (!vma || (m.addr != vma->vm_start) || - ((m.addr + (m.num<vm_end) || + ((m.addr + ((unsigned long)m.num<vm_end) || !privcmd_enforce_singleshot_mapping(vma)) { up_read(&mm->mmap_sem); return -EINVAL;